﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using weikebuluo.DAL;
using System.Data;
using weikebuluo.Common;

namespace weikebuluo.web.wechat.api
{
    public partial class article : System.Web.UI.Page
    {
        public string WeChat_Name = "";
        public string WeChat_OriginalID = "";
        public string Article_Title = "";
        public string Article_MainContent = "";
        public string Article_CreateTime = "";
        public string Article_PicUrl = "";
        public string Article_Description = "";

        w_wechat_dal wechatdal = new w_wechat_dal();
        w_article_dal articledal = new w_article_dal();

        protected void Page_Load(object sender, EventArgs e)
        {
            string Article_ID = Request.QueryString["aid"];

            if (!string.IsNullOrEmpty(Article_ID))
            {
                DataTable dtArticle = articledal.GetList("article_id=" + Article_ID).Tables[0];


                if (dtArticle.Rows.Count > 0)
                {
                    string user_id = dtArticle.Rows[0]["useer_id"].ToString();
                    Article_Title = dtArticle.Rows[0]["article_title"].ToString();
                    Article_MainContent = dtArticle.Rows[0]["article_content"].ToString();
                    Article_PicUrl = dtArticle.Rows[0]["article_picurl"].ToString();
                    Article_Description = dtArticle.Rows[0]["article_description"].ToString();
                    DateTime Dt = Convert.ToDateTime(dtArticle.Rows[0]["article_addtime"]);
                    Article_CreateTime = Dt.ToString("yyyy-MM-dd");

                    DataTable dtWeChat = wechatdal.GetList("user_id=" + user_id).Tables[0];

                    if (dtWeChat.Rows.Count > 0)
                    {
                        WeChat_Name = dtWeChat.Rows[0]["wechat_name"].ToString();
                        WeChat_OriginalID = dtWeChat.Rows[0]["wechat_originalid"].ToString();
                    }
                }
                else
                {

                    string htmlCode = FileOperate.ReadHtml("/wxgzpt/WeChat/Error.htm");
                    Response.Write(htmlCode.Replace("错误信息", "抱歉，找不到此文章"));
                    Response.End();
                }
            }
            else
            {
                string htmlCode = FileOperate.ReadHtml("/wxgzpt/WeChat/Error.htm");
                Response.Write(htmlCode.Replace("错误信息", "抱歉，找不到此文章"));
                Response.End();
            }
        }
    }
}